package strategy.b;

public abstract class Duck {
	
	/**
	 * 飞的行为属性
	 */
	FlyBehavior flyBehavior;
	
	/**
	 * 叫的行为属性
	 */
	QuackBehavior quackBehavior;
	
	/**
	 * 讲话的行为属性
	 */
	SpeakBehavior speakBehavior;
	
	void swim() {}
	
	abstract void display();
	
	/**
	 * 飞
	 */
	void performFly() {
		flyBehavior.fly();
	}
	
	/**
	 * 叫
	 */
	void performQuack() {
		quackBehavior.quack();
	}
	
	/**
	 * 说话
	 */
	void performSpeak() {
		speakBehavior.speak();
	}

	
	/********************************************************************/
	
	public void setFlyBehavior(FlyBehavior flyBehavior) {
		this.flyBehavior = flyBehavior;
	}

	public void setQuackBehavior(QuackBehavior quackBehavior) {
		this.quackBehavior = quackBehavior;
	}

	public void setSpeakBehavior(SpeakBehavior speakBehavior) {
		this.speakBehavior = speakBehavior;
	}
	
}
